package com.daycomtech.jgooglechart.charts;

import java.io.UnsupportedEncodingException;
import java.util.ArrayList;

import com.daycomtech.jgooglechart.JGChartConstants;
import com.daycomtech.jgooglechart.util.JGChartMakerStringUtil;

public class JGBarChart extends JGChart
{
	//Available types
	static public final String BarChartVS = JGChartConstants.BarChartVS;
	static public final String BarChartHS = JGChartConstants.BarChartHS;

	static public final String BarChartVG = JGChartConstants.BarChartVG;
	static public final String BarChartHG = JGChartConstants.BarChartVG;


	public int barWidth=0;
	public int barSpacing=0;

	public JGBarChart (int width, int height, String type)
	{
		super(width, height);
		super.setType(type);
	}

	public JGBarChart(int height, String type)
	{
		super(height);
		super.setType(type);
	}

	public JGBarChart(String type)
	{
		super.setType(type);
	}

	@Override
	public String getUrlString() throws UnsupportedEncodingException
	{
		String urlString="";

		ArrayList<String> urlStringParts = new ArrayList<String>();

		String chartSizeS = JGChartMakerStringUtil.getChartSize(super.getWidth(), super.getHeight());
		urlStringParts.add(chartSizeS);

		String chartDataS = JGChartMakerStringUtil.getChartData(super.getData());
		urlStringParts.add(chartDataS);

		String chartDataScalingS = JGChartMakerStringUtil.getChartDataScaling(super.getDataScalingMinValue(), super.getDataScalingMaxValue());
		urlStringParts.add(chartDataScalingS);


		String chartTypeS = JGChartMakerStringUtil.getChartType(super.getType());
		urlStringParts.add(chartTypeS);

		String chartLabelsS = JGChartMakerStringUtil.getChartLabels(super.getLabels());
		urlStringParts.add(chartLabelsS);

		String chartColorsS = JGChartMakerStringUtil.getChartColors(super.getColors());
		urlStringParts.add(chartColorsS);

		String chartAxisS = JGChartMakerStringUtil.getChartAxis(super.getChartAxis());
		urlStringParts.add(chartAxisS);

		String chartBarWidthAndSpacingS = JGChartMakerStringUtil.getChartBarWidthAndSpacing(barWidth,barSpacing);
		urlStringParts.add(chartBarWidthAndSpacingS);

		String chartGridLinesS = JGChartMakerStringUtil.getChartGridLines(super.getGridLines());
		urlStringParts.add(chartGridLinesS);

		urlString = JGChartMakerStringUtil.getUrlString(urlStringParts);


		return urlString;
	}

	public int getBarWidth() {
		return barWidth;
	}

	public void setBarWidth(int barWidth) {
		this.barWidth = barWidth;
	}

	public int getBarSpacing() {
		return barSpacing;
	}

	public void setBarSpacing(int barSpacing) {
		this.barSpacing = barSpacing;
	}


}
